﻿//This filter is tested and seems to work correctly

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace LowLevelGraphics.Filter
{
    /// <summary>
    /// Bottom edge filter
    /// </summary>
    public class BottomEdge : BaseImageFilter
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="BottomEdge"/> class.
        /// </summary>
        public BottomEdge()
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="BottomEdge"/> class.
        /// </summary>
        /// <param name="_bottomEdge">The _bottom edge.</param>
        internal BottomEdge(BottomEdge _bottomEdge)
        { 
        }

        /// <summary>
        /// Execute this Filter
        /// A Debug Statement is written if a concrete Filter is called
        /// </summary>
        /// <param name="_bitmap"></param>
        /// <returns></returns>
        public override UnsafeBitmap Execute(UnsafeBitmap _bitmap)
        {
            UnsafeBitmap bitmap = _bitmap;
            CConvMatrix convMatrix = new CConvMatrix();
            convMatrix.TopLeft = 1;
            convMatrix.TopMid = 1;
            convMatrix.TopRight = 1;
            convMatrix.MidLeft = 1;
            convMatrix.Pixel = 1;
            convMatrix.MidRight = 1;
            convMatrix.BottomLeft = -2;
            convMatrix.BottomMid = -2;
            convMatrix.BottomRight = -2;
            new Convolution3x3(convMatrix).Execute(bitmap);
            return _bitmap;
        }

        /// <summary>
        /// This is used to clone a filter, each filter must implement it's own clone functionality
        /// </summary>
        /// <returns></returns>
        public override object Clone()
        {
            return new BottomEdge(this);
        }
    }
}
